home *** CD-ROM | disk | FTP | other *** search
- Path: news.iag.net!news
- From: jatmon@iag.net (John R Buchan)
- Newsgroups: comp.lang.c
- Subject: Re: Constructor?
- Followup-To: comp.lang.c++
- Date: 13 Jan 1996 19:31:06 GMT
- Organization: Internet Access Group, Orlando, Florida
- Message-ID: <4d919q$pq2@news.iag.net>
- References: <00001a80+00006b6c@msn.com>
- NNTP-Posting-Host: pm2-orl3.iag.net
- X-Newsreader: WinVN 0.99.7
-
- In article <00001a80+00006b6c@msn.com>, Pacu@msn.com says...
- >
- >In a program example, I saw something similar to the following:
- >
- > public:
- > CString str;
- > (etc..)
-
- I am assuming that this is inside of the declaration of a class or struct.
- I'll call it MyClass.
-
- This is defining a member of this class named str as type CString. No
- constructor is called at this point.
-
- The CString constructor will be called, when an object of type MyClass is
- created (instanciated) at some point in the code, as with the CString object
- below. The process of creating the MyClass object creates a CString object,
- since it is a member. This necessitates calling the CString constructor.
-
- >
- >
- > Later, in a function, I saw:
- >
- > Function()
- >
- > Cstring str;
-
- This is defining an object named str of type CString. The CString
- constructor will be called, when this code is executed.
-
- MyClass obj.
-
- When executed, this will create a MyClass object. The process will involve
- creating a CString object (the member str).
-
- > (etc..)
- >
- >In episode one, is it declaring str to be of CString type or is it
- >constructed there? And in the second instance, inside of the
- >function, is it being constructed or is it a variable of CString
- >type? If this example is too vague, I will try to find the missing
- >pieces, but I ask it in a general sense concerning the nature of
- >constuctors and variable tpe declaration. Any help is appreciated via
- >personal e-mail. Pacu.
- >
-
- This is definitely a C++ question, not C. I'm quite rusty on C++, but
- I'm sure someone will correct any errors. Followups are redirected to
- comp.lang.c++.
-
- --
- John R Buchan -:|:- Looking for that elusive FAQ? ftp to:
- jatmon@mail.iag.net -:|:- rtfm.mit.edu /pub/usenet-by-group/....
-
-